/*
 * sandbox.c
 *
 * Copyright (C) 2011 - Dr.NP
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @version sandbox.c
 * @package exts/as3sandbox
 * @author Dr.NP <np@bsgroup.org>
 * @update 07/26/2011
 */

/**
 * ActionScript sandbox service
 * Default listen at TCP port 843
 * Return a XML string and close connection then
 * 
 * === CHANGELOG ===
 * [07/26/2011] - Creation
 */

#include "bsp.h"
#include "bsp_app.h"
#include "bsp_script.h"

#include <stdio.h>
#include <string.h>

#include "as3sandbox.h"

void sandbox_on_load(int);
void sandbox_on_unload(int);
void sandbox_on_conn(int);
void sandbox_on_close(int);
size_t sandbox_on_data(int, char *, size_t);
void sandbox_on_error(int);

struct bsp_ext_entry_t entry = 
{
    sandbox_on_load, 
    sandbox_on_unload, 
    sandbox_on_conn, 
    sandbox_on_close, 
    sandbox_on_data, 
    sandbox_on_error
};

BSP_EXTENSION bsp_as3sandbox = {
    1, 
    "as3sandbox", 
    &entry, 
    NULL
};

void sandbox_on_load(int app_id)
{
    return;
}

void sandbox_on_unload(int app_id)
{
    return;
}

void sandbox_on_conn(int clt_id)
{
    return;
}

void sandbox_on_close(int clt_id)
{
    return;
}

size_t sandbox_on_data(int clt_id, char *data, size_t len)
{
    append_client(clt_id, SANDBOX_RESPONSE_STR, strlen(SANDBOX_RESPONSE_STR) + 1);
    
    return len;
}

void sandbox_on_error(int clt_id)
{
    return;
}
